<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>授权验证</title>
    <link rel="shortcut icon" href="/static/icon/doc_favicon.ico">
    <link href="/static/hplus/css/bootstrap.min.css?v=<?php echo time()?>" rel="stylesheet">
    <link href="/static/hplus/css/style.css" rel="stylesheet">
</head>
<body class="gray-bg">
<div class="middle-box text-center loginscreen  animated fadeInDown">
    <div style="height: 200px;"></div>
    <h3>授权验证</h3>
    <div class="form-group">
        <input type="password" id="pwd" name="pwd" class="form-control" placeholder="请输入文档密码">
    </div>
    <input type="button" id="submit" class="btn btn-primary block full-width" value="验证">
</div>
</body>
<script type="text/javascript" src="/static/hplus/js/jquery.min.js?v=<?php echo time()?>"></script>
<script type="text/javascript" src="/static/layer/layer.js?v=<?php echo time()?>"></script>
<script type="text/javascript">
    $(function () {
        $(document).keydown(function (e) {
            if (e.keyCode === 13) {
                $('#submit').click();
            }
        })
        $('#submit').click(function () {
            let $this = $(this)
            let pwd = $('#pwd');
            if (pwd.val() === '') {
                layer.msg('请输入文档密码', {icon: 2, time: 1500}, function () {
                    pwd.focus();
                    return false;
                });
            } else if ($this.data('doing') !== '1') {
                $.ajax({
                    type: 'post', dataType: 'json', cache: false,
                    url: '{:url("info")}',
                    data: {'id': '{$id}', 'pwd': pwd.val()},
                    beforeSend: function () {
                        $this.data('doing', 1)
                    },
                    success: function (msg) {
                        $this.data('doing', 0)
                        if (msg.code === 200) {
                            layer.msg(msg.message, {icon: 1, time: 1000}, function () {
                                //location.href = '{:url("info", ["id" => $id])}';
                                location.reload()
                            });
                        } else {
                            layer.msg(msg.message, {icon: 2, time: 1500});
                        }
                    },
                    error: function (msg) {
                        console.log(msg)
                    }
                });
            }
        });
    });
</script>
</html>